{% extends '/layout.html' %}

{% block title %}参赛作品评选系统 - 欢迎登录{% endblock %}

{% block body %}

<li><a href="{{ url_for('users.login')}}">去登录</a></li>
<h1>我是首页</h1>
<h2 id="h2">当前登录用户：无</h2>
<br/>

<script type="text/javascript">

    function getCookie(cookie_name) {
          var name = cookie_name + "=";
          var ca = document.cookie.split(';');
          for(var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') {
              c = c.substring(1);
            }
            if (c.indexOf(name) == 0) {
              return c.substring(name.length, c.length);
            }
          }
          return "";
    }

    $(document).ready(function() {
        name = getCookie('user_name')
        $('#h2').text('当前登录用户：'+ name)
    });
</script>
{% endblock %}